using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using LINDFINANCIAL_API_COMPONENTLib;


namespace Metro.SmartClient.LindFinancialFoundation
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] iRecords = null;
            string cStatus;
            LindClass ConnectionInstance = new LindClass();

            Console.WriteLine("Connecting ....");
            ConnectionInstance.StartConnection();
            cStatus = ConnectionInstance.ConnectionStatus;
            Console.WriteLine("{0}", cStatus);

            if (cStatus == "Connected")
            {

                //ConnectionInstance.OnRequestFunds(null, null);  
                //Console.WriteLine("Consulta de Instrumento ....");
                //ConnectionInstance.QuoteInformation("MSFT1C", new DateTime(2008, 9, 15));

                //Thread.Sleep(7000);
                //string[] quotes = ConnectionInstance.quotes.Split('*');
                //foreach (Object quote in quotes)
                //    Console.WriteLine("{0}", quote);


                //Console.WriteLine("Consulta de Fondos ....");
                //ConnectionInstance.GetFundInformation();
                Console.WriteLine("Put test Order ....");
                ConnectionInstance.PutOrder(5, 0, new DateTime(2008, 9, 15), TransactionType.Buy, "AMZN1C", OrderType.MARKET);  


                //Console.WriteLine("Requesting Record ....");
                //ConnectionInstance.SendRequest(LINDFINANCIAL_API_COMPONENTLib.RequestType.RQT_ORDERS);

                //Thread.Sleep(7000);
                //iRecords = ConnectionInstance.StatusRecord.Split('*');
                //foreach (Object Record in iRecords)
                //    Console.WriteLine("{0}", Record);



                Console.WriteLine("\nDone. Press any key");
                //Console.Read();
                //Console.WriteLine("\nCancel Order");
                //ConnectionInstance.CancelOrder(ConnectionInstance.orderNumber,ConnectionInstance.orderIdentifier);
                Console.Read();

                ConnectionInstance.SendRequest(LINDFINANCIAL_API_COMPONENTLib.RequestType.RQT_ORDERS);

                Thread.Sleep(7000);
                iRecords = ConnectionInstance.StatusRecord.Split('*');
                foreach (Object Record in iRecords)
                    Console.WriteLine("{0}", Record);

                Console.Read();
                ConnectionInstance.EndConnection();

            }
        }
    }
}

